/**
  * Created by wyc on 6/11/2017.
  */
package ninenineqs

object p07 {
  def flatten_v1(input:List[Any]):List[Any] = {
    input.flatMap( _ match {
      case l:List[Any] => flatten_v1(l)
      case h:Any => List(h)
    })
  }
  def flatten_v2(input:List[Any]):List[Any] = {
    input match {
      case Nil => Nil
      case (h:List[Any]) :: tail => flatten_v2(h) ++ flatten_v2(tail)
      case h :: tail => h :: flatten_v2(tail)
    }
  }
}

